package com.godz.frontData;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.godz.mapper.loginrootMapper;
import com.godz.pojo.root.loginroot;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController
public class LoginPass {
    final
    loginrootMapper loginMapper;

    public LoginPass(loginrootMapper loginMapper) {
        this.loginMapper = loginMapper;
    }

    @PostMapping("/login/root/password")
    public boolean Verification(@RequestBody loginroot loginroot1) {
        String username = loginroot1.getUsername();
        String password = loginroot1.getPassword();

        QueryWrapper<loginroot> wrapper = new QueryWrapper<>();
        wrapper.like("username", username);

        loginroot loginroot2 = loginMapper.selectOne(wrapper);
        if(loginroot2==null){
            return false;
        }
        String password1 = loginroot2.getPassword();

        if (Objects.equals(password, password1)) {
            System.out.println("发送的密码:" + password + " 数据库的密码:" + password1);
            return true;
        }
        return false;
    }
}
